#include"Http.hpp"
#include<functional>
#include"Util.hpp"
#include<memory>
void Login(HttpRequst& req,HttpRespone& res){
    LOG(LogLevel::INFO)<<"Login request received";
    res.Setcode(200);
    res.SetHeader("Content-Type","text/html");
    std::string body;
    Util::ReadFileContent("wwwroot/LG.html",&body);
    res.setText(body);
}
int main(int argc,char*argv[]){
    if(argc!=2){
        std::cout<<"Usage:./myHttp port"<<std::endl;
        return 1;
    }
    uint16_t port=atoi(argv[1]);
    std::unique_ptr<Http> server=std::make_unique<Http>(port);
    auto login=std::bind(Login,std::placeholders::_1,std::placeholders::_2);
    server->RegisterHttpFunc("/Login",login);
    server->Start();
    return 0;
}